﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;

namespace Vision.VisionWorkshop.Controls
{
    /// <summary>
    /// This is the view-model of the UI.  It provides a data source
    /// for the TreeView.
    /// </summary>
    public class TypeBrowserViewModel
    {
        readonly ReadOnlyCollection<TypeViewModel> firstGeneration;

        public TypeBrowserViewModel(IList<TypeInfo> rootPersons)
        {
            this.firstGeneration = new ReadOnlyCollection<TypeViewModel>(
                (from person in rootPersons
                 select new TypeViewModel(person))
                .ToList());
        }

        /// <summary>
        /// Returns a read-only collection containing the first person 
        /// in the family tree, to which the TreeView can bind.
        /// </summary>
        public ReadOnlyCollection<TypeViewModel> FirstGeneration
        {
            get { return this.firstGeneration; }
        }
    }
}